<template>
    <div id="app">
        <router-view />
    </div>
</template>

<script>
export default {
    name: "App",
    beforeCreate() {
        /* 判断是否是移动设备登录 */
        let flag = navigator.userAgent.match(
            /(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i
        )
        if(!flag){
            document.getElementsByTagName('body')[0].className = 'minW1440'
        }
    },
    created() {
        //在页面加载时读取localStorage里的状态信息
        if (sessionStorage.getItem("userMsg")) {
            this.$store.replaceState(
                Object.assign(
                    {},
                    this.$store.state,
                    JSON.parse(sessionStorage.getItem("userMsg"))
                )
            );
        }
        //在页面刷新时将vuex里的信息保存到localStorage里
        window.addEventListener("beforeunload", () => {
            sessionStorage.setItem(
                "userMsg",
                JSON.stringify(this.$store.state)
            );
        });
    },
};
</script>

<style lang="less">
html,body,#app {
    height: 100%;
    font-family:Microsoft YaHei-Regular, Microsoft YaHei;
}
@font-face{
    font-family: 'Auto Digital-Bold, Auto Digital';
    src: url(./assets/font/auto_digital.ttf);
}
@font-face{
    font-family: 'FZZhengHeiS-DB-GB-Regular, FZZhengHeiS-DB-GB';
    src: url(./assets/font/fzzhengheis-db-gb.ttf);
}
.minW1440{
    min-width: 1440px;
}
ul{
    list-style: none;
}
</style>
